<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 联想小鑫
  Date: 2021/11/15
  Time: 9:17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="js/jquery-1.8.2.min.js"></script>
</head>
<body>
<form action="list.do" method="post">
    订单日期:
    <input type="text" name="dddatex" value="${dddatex}">-----
    <input type="text" name="dddated" value="${dddated}">
    <br>
    订单编号:<input type="text" name="ddbh" value="${ddbh}"> <br>
    客户名称:<input type="text" name="name" value="${name}"> <br>
    优先级:<input type="text" name="yxj" value="${yxj}"> <br>
    总金额:
    <input type="text" name="pricex" value="${pricex}">-------
    <input type="text" name="priced" value="${priced}">
    <br>
    备注:<input type="text" name="beizhu" value="${beizhu}"> <br>
    联系人:<input type="text" name="lxr" value="${lxr}"> <br>
    送货地址:<input type="text" name="address" value="${address}"> <br>
    联系电话:<input type="text" name="phone" value="${phone}"> <br>
    制单人工号:<input type="text" name="gh" value="${gh}"> <br>
    制单人:<input type="text" name="zdname" value="${zdname}"> <br>
    制单时间:
    <input type="text" name="zddatex" value="${zddatex}">---------
    <input type="text" name="zddated" value="${zddated}">
    <br>
    <input type="submit" value="查询">
</form>
<button id="addy">新增</button>
<table border="1">
    <tr>
        <td></td>
        <td>序号</td>
        <td>订单日期</td>
        <td>订单编号</td>
        <td>客户名称</td>
        <td>优先级</td>
        <td>总金额</td>
        <td>备注</td>
        <td>联系人</td>
        <td>送货地址</td>
        <td>联系电话</td>
        <td>制单人工号</td>
        <td>制单人</td>
        <td>制单时间</td>
        <td>附件</td>
    </tr>
    <c:forEach items="${list}" var="s">
        <tr>
            <td><input type="checkbox" value="${s.id}"></td>
            <td>${s.id}</td>
            <td>${s.dddate}</td>
            <td>${s.ddbh}</td>
            <td>${s.name}</td>
            <td>${s.yxj}</td>
            <td>${s.price}</td>
            <td>${s.beizhu}</td>
            <td>${s.lxr}</td>
            <td>${s.address}</td>
            <td>${s.phone}</td>
            <td>${s.gh}</td>
            <td>${s.zdname}</td>
            <td>${s.zddate}</td>
            <td>${s.fujian}</td>
        </tr>
    </c:forEach>
    <tr>
        <td colspan="20" align="center">
            <button onclick="go(1)">首页</button>
            <button onclick="go(${page.getPageNum()}-1)">上一页</button>
            <button onclick="go(${page.getPageNum()}+1)">下一页</button>
            <button onclick="go(${page.getPages()})">尾页</button>
        </td>
    </tr>
    <tr>
        <td colspan="20" align="center">
            <button id="qx">全选</button>
            <button id="qbx">全不选</button>
            <button id="fx">反选</button>
            <button id="ps">批量删除</button>
        </td>
    </tr>
</table>
</body>
<script>
    function go(pageNum) {
        location="list.do?pageNum="+pageNum+"&"+$("form").serialize();
    }
    $("#addy").click(function () {
        location="/addy.do";
    })
    $("#qx").click(function () {
        $(":checkbox").attr("checked",true);
    })
    $("#qbx").click(function () {
        $(":checkbox").attr("checked",false);
    })
    $("#fx").click(function () {
        $(":checkbox").each(function () {
            $(this).attr("checked",!$(this).attr("checked"));
        })
    })
    $("#ps").click(function () {
        var id ="";
        $(":checkbox:checked").each(function () {
            id+=","+$(this).val();
        })
        id=id.substring(1);
        if(id.length>0){
            if(confirm("您确认删除序号为"+id+"的数据吗?")){
                $.ajax({
                    url:"delids.do",
                    data:{"id":id},
                    dataType:"json",
                    type:"post",
                    success:function (a) {
                        if(a>0){
                            alert("删除成功");
                                location="list.do";
                        }
                    }
                })
            }
        }else{
            alert("请至少选择一条数据")
        }
    })
</script>
</html>
